package cn.virens.web.controller.manage.wxmp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.virens.common.RequestUtil;
import cn.virens.components.page.PageParamUser;
import cn.virens.components.page.PageResult;
import cn.virens.database.mysql.model.wxmp.WxmpBase;
import cn.virens.service.inter.platform.wxmp.WxmpBaseService;
import cn.virens.web.common.BaseTableController;

/**
 * 公众号 - wxmp_base
 *
 * @author Virens
 * @since  2019-11-09
 */
@Controller
@RequestMapping("/manage/wxmp/base")
public class WxmpBaseContorller extends BaseTableController<WxmpBase, WxmpBaseService> {

	public WxmpBaseContorller() {
		super("/manage/wxmp/base", "wxmp:base");
	}

	@Override
	protected PageResult<?> listHandle(HttpServletRequest request, PageParamUser pageParam) throws Exception {
		pageParam.addParam("appid", RequestUtil.getValueStr(request, "appid"));
		pageParam.addParam("name", RequestUtil.getValueStr(request, "name"));

		return super.listHandle(request, pageParam);
	}

	@RequestMapping("view.jspx")
	public String viewJspx(HttpServletRequest request, HttpServletResponse response, Model model) {
		model.addAttribute("record", mBaseService.selectOne(RequestUtil.getValueInt(request, "id")));

		return returnUrl("view");
	}

	@RequestMapping("create.jspx")
	public String createJspx(HttpServletRequest request, HttpServletResponse response, Model model) {
		return returnUrl("create");
	}

	@RequestMapping("update.jspx")
	public String updateJspx(HttpServletRequest request, HttpServletResponse response, Model model) {
		model.addAttribute("record", mBaseService.selectOne(RequestUtil.getValueInt(request, "id")));

		return returnUrl("update");
	}

}
